<?php
/**
 * 公共控制器
 * User: fengyan
 * Date: 2017/8/27
 * Time: 下午5:47
 */

namespace App\Http\Controllers\Admin;

use App\Exceptions\MyException;
use App\Repositories;
class PublicController extends AdminController
{
    /**
     * 后台主页
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return $this->fetch(config('admin.systems.index_blade'));
    }

    /**
     * 控制台
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function main()
    {
        $count['news'] = Repositories\Portal\DocumentRepository::getInstance()->getSelectModel([
            'document_type' => 'news'
        ])->count();

        $count['photo'] = Repositories\Portal\DocumentRepository::getInstance()->getSelectModel([
            'document_type' => 'photo'
        ])->count();

        $count['page'] = Repositories\Portal\DocumentRepository::getInstance()->getSelectModel([
            'document_type' => 'page'
        ])->count();

        $count['category'] = Repositories\Portal\CategoryRepository::getInstance()->getSelectModel([])->count();
        return $this->fetch(config('admin.systems.main_blade'), ['count'=>$count]);
    }

    /**
     * 获取当前控制器服务仓库对象
     * @return mixed
     */
    public function getServiceRepository()
    {
        // TODO: Implement getServiceRepository() method.
    }

    public function test()
    {
        return view('admin.test');
    }

    public function showError()
    {
        $msg = '';
        $url = '';
        $data = [];
        $wait = 2;
        $httpStatus = 200;
        $header = [];
        return $this->error($msg, $url, $data, $wait, $httpStatus, $header);
    }

    public function showSuccess()
    {
        $msg = '';
        $url = '';
        $data = [];
        $wait = 2;
        $httpStatus = 200;
        $header = [];
        return $this->success($msg, $url, $data, $wait, $httpStatus, $header);
    }
}